package com.example.myapplication.kotlinroom

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase

@Database(entities = [UserRoomK::class],version = 1,exportSchema = false)
abstract class UserRoomKDb:RoomDatabase() {
    abstract fun userRoomKDao():UserRoomKDao
    companion object{
        @Volatile
        private var instance:UserRoomKDb? =null
        @Synchronized
        fun get(context: Context):UserRoomKDb{
            if (instance == null){
                instance = Room.databaseBuilder(
                        context.applicationContext,
                        UserRoomKDb::class.java,
                        "user_room_k.db")
//                        .openHelperFactory(SupportFactory(SQLiteDatabase.getBytes("1111".toCharArray())))
                        .build()
            }
            return instance!!
        }
    }
}